{
  "properties" : { },
  "id" : "b5721004769844afa5114566885fa4fc",
  "script" : null,
  "groupId" : "9e0a5d32171c4700a791fb1f1eb129c5",
  "name" : "客户类型统计",
  "createTime" : null,
  "updateTime" : 1663047317294,
  "lock" : null,
  "createBy" : null,
  "updateBy" : null,
  "path" : "/",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ {
    "name" : "default_data_source",
    "value" : "cks_dev",
    "description" : "配置默认数据源的key",
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": 200,\n    \"message\": \"success\",\n    \"data\": {\n        \"process\": [{\n            \"typeCode\": \"11\",\n            \"facnum\": 12,\n            \"facs\": [{\n                \"id\": 17,\n                \"fac\": \"白云山和黄\",\n                \"dataowner\": \"005240855736\",\n                \"typeCode\": \"11\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:31:56\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 18,\n                \"fac\": \"华润三九\",\n                \"dataowner\": \"005241071182\",\n                \"typeCode\": \"11\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:32:34\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 19,\n                \"fac\": \"澳诺制药\",\n                \"dataowner\": \"005412324462\",\n                \"typeCode\": \"11\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:32:39\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 20,\n                \"fac\": \"天津达仁堂\",\n                \"dataowner\": \"005244035748\",\n                \"typeCode\": \"11\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:32:40\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 21,\n                \"fac\": \"河北紫翔\",\n                \"dataowner\": \"005462379177\",\n                \"typeCode\": \"11\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:32:40\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 22,\n                \"fac\": \"武汉健民\",\n                \"dataowner\": \"005344537533\",\n                \"typeCode\": \"11\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:32:57\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 23,\n                \"fac\": \"马应龙\",\n                \"dataowner\": \"005272956955\",\n                \"typeCode\": \"11\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:33:09\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 24,\n                \"fac\": \"上海雷允上\",\n                \"dataowner\": \"005350421509\",\n                \"typeCode\": \"11\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:33:09\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 25,\n                \"fac\": \"红珊瑚\",\n                \"dataowner\": \"005324686149\",\n                \"typeCode\": \"11\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:33:14\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 26,\n                \"fac\": \"江西冠灵\",\n                \"dataowner\": \"005426623605\",\n                \"typeCode\": \"11\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:33:15\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 27,\n                \"fac\": \"山东方明\",\n                \"dataowner\": \"005256545611\",\n                \"typeCode\": \"11\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:33:17\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 28,\n                \"fac\": \"山西明美\",\n                \"dataowner\": \"005430406618\",\n                \"typeCode\": \"11\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:33:17\",\n                \"enable\": \"Y\"\n            }]\n        }, {\n            \"typeCode\": \"12\",\n            \"facnum\": 5,\n            \"facs\": [{\n                \"id\": 1,\n                \"fac\": \"厦门片仔癀宏仁\",\n                \"dataowner\": \"005345707905\",\n                \"typeCode\": \"12\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 16:33:57\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 2,\n                \"fac\": \"海南快克\",\n                \"dataowner\": \"000052138104\",\n                \"typeCode\": \"12\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 16:38:35\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 3,\n                \"fac\": \"信谊联合\",\n                \"dataowner\": \"005260233045\",\n                \"typeCode\": \"12\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 16:43:57\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 4,\n                \"fac\": \"伟沂企业\",\n                \"dataowner\": \"005272925252\",\n                \"typeCode\": \"12\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 16:49:09\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 5,\n                \"fac\": \"广东心宝\",\n                \"dataowner\": \"005432120396\",\n                \"typeCode\": \"12\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 16:51:54\",\n                \"enable\": \"Y\"\n            }]\n        }, {\n            \"typeCode\": \"13\",\n            \"facnum\": 5,\n            \"facs\": [{\n                \"id\": 6,\n                \"fac\": \"天津力生\",\n                \"dataowner\": \"005319616183\",\n                \"typeCode\": \"13\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 16:55:51\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 7,\n                \"fac\": \"深圳瑞霖\",\n                \"dataowner\": \"005258343344\",\n                \"typeCode\": \"13\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:00:22\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 8,\n                \"fac\": \"华润生物\",\n                \"dataowner\": \"005411993527\",\n                \"typeCode\": \"13\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:02:53\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 9,\n                \"fac\": \"碧生源\",\n                \"dataowner\": \"005293134871\",\n                \"typeCode\": \"13\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:06:52\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 10,\n                \"fac\": \"北京华鸿\",\n                \"dataowner\": \"005240587231\",\n                \"typeCode\": \"13\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:10:44\",\n                \"enable\": \"Y\"\n            }]\n        }, {\n            \"typeCode\": \"14\",\n            \"facnum\": 6,\n            \"facs\": [{\n                \"id\": 11,\n                \"fac\": \"南京圣和\",\n                \"dataowner\": \"005246043646\",\n                \"typeCode\": \"14\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:14:25\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 12,\n                \"fac\": \"江苏万邦\",\n                \"dataowner\": \"005241165679\",\n                \"typeCode\": \"14\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:19:02\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 13,\n                \"fac\": \"大鹏药品\",\n                \"dataowner\": \"005293163260\",\n                \"typeCode\": \"14\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:21:44\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 14,\n                \"fac\": \"上药销售\",\n                \"dataowner\": \"005260233043\",\n                \"typeCode\": \"14\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:26:28\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 15,\n                \"fac\": \"白云山花城\",\n                \"dataowner\": \"005448907641\",\n                \"typeCode\": \"14\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:27:51\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 16,\n                \"fac\": \"福瑞达\",\n                \"dataowner\": \"005410007943\",\n                \"typeCode\": \"14\",\n                \"type1\": \"0\",\n                \"type2\": \"0\",\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:31:47\",\n                \"enable\": \"Y\"\n            }]\n        }],\n        \"clean\": [{\n            \"typeCode\": \"21\",\n            \"facnum\": 2,\n            \"facs\": [{\n                \"id\": 29,\n                \"fac\": \"马应龙\",\n                \"dataowner\": \"\",\n                \"typeCode\": \"21\",\n                \"type1\": \"2\",\n                \"type2\": \"1\",\n                \"updateInterval\": \"日\",\n                \"updatedTime\": \"2022-09-12 17:36:10\",\n                \"enable\": \"Y\"\n            }, {\n                \"id\": 30,\n                \"fac\": \"桂林三金\",\n                \"dataowner\": \"\",\n                \"typeCode\": \"21\",\n                \"type1\": null,\n                \"type2\": null,\n                \"updateInterval\": \"月\",\n                \"updatedTime\": \"2022-09-12 17:37:00\",\n                \"enable\": \"Y\"\n            }]\n        }]\n    },\n    \"timestamp\": 1663039201868,\n    \"executeTime\": 26\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : {
    "name" : "",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : null,
    "defaultValue" : null,
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "code",
      "value" : "200",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "message",
      "value" : "success",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "data",
      "value" : "",
      "description" : "",
      "required" : false,
      "dataType" : "Object",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ {
        "name" : "process",
        "value" : "",
        "description" : "",
        "required" : false,
        "dataType" : "Array",
        "type" : null,
        "defaultValue" : null,
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ {
          "name" : "",
          "value" : "",
          "description" : "",
          "required" : false,
          "dataType" : "Object",
          "type" : null,
          "defaultValue" : null,
          "validateType" : "",
          "error" : "",
          "expression" : "",
          "children" : [ {
            "name" : "typeCode",
            "value" : "11",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "facnum",
            "value" : "12",
            "description" : "",
            "required" : false,
            "dataType" : "Integer",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "facs",
            "value" : "",
            "description" : "",
            "required" : false,
            "dataType" : "Array",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ {
              "name" : "",
              "value" : "",
              "description" : "",
              "required" : false,
              "dataType" : "Object",
              "type" : null,
              "defaultValue" : null,
              "validateType" : "",
              "error" : "",
              "expression" : "",
              "children" : [ {
                "name" : "id",
                "value" : "17",
                "description" : "",
                "required" : false,
                "dataType" : "Integer",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "fac",
                "value" : "白云山和黄",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "dataowner",
                "value" : "005240855736",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "typeCode",
                "value" : "11",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "type1",
                "value" : "0",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "type2",
                "value" : "0",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "updateInterval",
                "value" : "月",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "updatedTime",
                "value" : "2022-09-12 17:31:56",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "enable",
                "value" : "Y",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              } ]
            } ]
          } ]
        } ]
      }, {
        "name" : "clean",
        "value" : "",
        "description" : "",
        "required" : false,
        "dataType" : "Array",
        "type" : null,
        "defaultValue" : null,
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ {
          "name" : "",
          "value" : "",
          "description" : "",
          "required" : false,
          "dataType" : "Object",
          "type" : null,
          "defaultValue" : null,
          "validateType" : "",
          "error" : "",
          "expression" : "",
          "children" : [ {
            "name" : "typeCode",
            "value" : "21",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "facnum",
            "value" : "2",
            "description" : "",
            "required" : false,
            "dataType" : "Integer",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "facs",
            "value" : "",
            "description" : "",
            "required" : false,
            "dataType" : "Array",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ {
              "name" : "",
              "value" : "",
              "description" : "",
              "required" : false,
              "dataType" : "Object",
              "type" : null,
              "defaultValue" : null,
              "validateType" : "",
              "error" : "",
              "expression" : "",
              "children" : [ {
                "name" : "id",
                "value" : "29",
                "description" : "",
                "required" : false,
                "dataType" : "Integer",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "fac",
                "value" : "马应龙",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "dataowner",
                "value" : "",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "typeCode",
                "value" : "21",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "type1",
                "value" : "2",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "type2",
                "value" : "1",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "updateInterval",
                "value" : "日",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "updatedTime",
                "value" : "2022-09-12 17:36:10",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              }, {
                "name" : "enable",
                "value" : "Y",
                "description" : "",
                "required" : false,
                "dataType" : "String",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ ]
              } ]
            } ]
          } ]
        } ]
      } ]
    }, {
      "name" : "timestamp",
      "value" : "1663039201868",
      "description" : "",
      "required" : false,
      "dataType" : "Long",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "executeTime",
      "value" : "26",
      "description" : "",
      "required" : false,
      "dataType" : "Object",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    } ]
  }
}
================================
def processTypes = db.select("select type_code,count(fac) fac_num from st_md_fac where type_code like '1%' group by type_code order by type_code")
for(item in processTypes){
    def facs = db.select("select * from st_md_fac where type_code = " + item.typeCode)
    item.facs = facs
}

def cleanTypes = db.select("select type_code,count(fac) fac_num from st_md_fac where type_code like '2%' group by type_code order by type_code")
for(item in cleanTypes){
    def facs = db.select("select * from st_md_fac where type_code = " + item.typeCode)
    item.facs = facs
}
return {"process":processTypes,"clean":cleanTypes};